<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>isPowerOfTwo</title>
</head>

<body>
    <p>检查给定数字是否是2的幂</p>
    <p id="result"></p>
    <script>
        const isPowerOfTwo = n => !!n && (n & (n - 1)) === 0;
        document.getElementById('result').innerHTML = `8${isPowerOfTwo(8) ? '' : '不'}是2的幂!`
    </script>
</body>

</html>